
#ifndef __DIMENSION_H__
#define __DIMENSION_H__

#include <list>
#include <string>

class Unit;
typedef std::list<const Unit*> UnitList;

class Unit
{
public:
    Unit(unsigned int conversionFactor, UnitList &list, const char *name);
    unsigned int toBaseUnit(unsigned int amount) const;
    bool isSameType(const Unit &unit) const;
    const UnitList& getUnitList() const;
    const std::string& getName() const;
private:
    unsigned int conversionFactor;
    UnitList &list;
    std::string name;
};

class Dimension
{
public:
    Dimension(unsigned int amount, const Unit& unit);
    bool operator==(const Dimension& dimension) const;
    bool operator!=(const Dimension& dimension) const;
#define DIFFERENT_UNIT_TYPE     1
    Dimension operator+(const Dimension& dimension) const throw (int);
    std::string toString() const;
    std::string toStringInSmallestUnit() const;
private:
    unsigned int getBaseAmount() const;
    unsigned int amount;
    const Unit& unit;
};

#endif

